package controller.link.game;

import view.client.Console;
import model.Hearer;
import java.io.Serializable;
import controller.Link;
import controller.link.RefreshGameData;
import model.User;
import model.Attendant;
import model.Server;

public class AddAtribute implements Link, Serializable {

    private String atribute;

    public AddAtribute(String atribute) {
        this.atribute = atribute;
    }

    public AddAtribute(Hearer h, String atribute) {
        this.atribute = atribute;

        h.send((Link) this);
    }

    @Override
    public void serverUse(Server server, Attendant at) {
        User user = at.getUser();
        if (user.getPlayer().getFreshAtributes() <= 0) {
            return;
        }
        if (atribute.equals("Agility")) {
            user.getPlayer().setAgility(user.getPlayer().getAgility() + 1);
        } else if (atribute.equals("Strength")) {
            user.getPlayer().setStrength(user.getPlayer().getStrength() + 1);
        } else if (atribute.equals("FirePower")) {
            user.getPlayer().setFirePower(user.getPlayer().getFirePower() + 1);
        } else if (atribute.equals("Intelligence")) {
            user.getPlayer().setIntelligence(user.getPlayer().getIntelligence() + 1);
        } else if (atribute.equals("Resistence")) {
            user.getPlayer().setResistence(user.getPlayer().getResistence() + 1);
        } else if (atribute.equals("Vigor")) {
            user.getPlayer().setVigor(user.getPlayer().getVigor() + 1);
        } else if (atribute.equals("Aptitude")) {
            user.getPlayer().setAptitude(user.getPlayer().getAptitude() + 1);
        }
        user.getPlayer().setFreshAtributes(user.getPlayer().getFreshAtributes() - 1);
        RefreshGameData rgd = new RefreshGameData();
        rgd.serverUse(server, at);
    }

    @Override
    public void clientUse(Console console) {
    }
}
